package com.zrwl.poscloud.core.restapi.admin.baseInfo;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.core.annotion.OperationLogger.OperationLogger;
import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.Delete;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.commons.validator.group.Insert;
import com.zrwl.poscloud.commons.validator.group.Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zrwl.poscloud.xo.service.MessageRtcService;
import com.zrwl.poscloud.xo.vo.MessageRtcVO;
/**
 * 实时通讯 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-03-17
 */
@RestController
@Api(value = "实时通讯相关接口", tags = {"实时通讯相关接口"})
@RequestMapping("/messageRtc")
@Slf4j
public class MessageRtcRestApi {
    @Autowired
    private MessageRtcService messageRtcService;
    @AuthorityVerify
    @ApiOperation(value = "获取实时通讯列表", notes = "获取实时通讯列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody MessageRtcVO messageRtcVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取实时通讯列表: {}", messageRtcVO);
        return ResultUtil.successWithData(messageRtcService.getPageList(messageRtcVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取实时通讯列表", notes = "获取实时通讯列表", response = String.class)
    @PostMapping("/getAllList")
    public String getAllList(@Validated({GetList.class}) @RequestBody MessageRtcVO messageRtcVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取实时通讯列表: {}", messageRtcVO);
        return ResultUtil.successWithData(messageRtcService.getAllList(messageRtcVO));
    }

    @AuthorityVerify
    @OperationLogger(value = "新增实时通讯")    @ApiOperation(value = "新增实时通讯", notes = "新增实时通讯", response = String.class)
    @PostMapping("/add")
    public String add(@Validated({Insert.class}) @RequestBody MessageRtcVO messageRtcVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("新增实时通讯: {}", messageRtcVO);
        return messageRtcService.add(messageRtcVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "修改实时通讯")    @ApiOperation(value = "修改实时通讯", notes = "修改实时通讯", response = String.class)
    @PostMapping("/edit")
    public String edit(@Validated({Update.class}) @RequestBody MessageRtcVO messageRtcVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("修改实时通讯: {}", messageRtcVO);
        return messageRtcService.edit(messageRtcVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "删除实时通讯")    @ApiOperation(value = "删除实时通讯", notes = "删除实时通讯", response = String.class)
    @PostMapping("/delete")
    public String delete(@Validated({Delete.class}) @RequestBody MessageRtcVO messageRtcVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("删除实时通讯: {}", messageRtcVO);
        return messageRtcService.delete(messageRtcVO);
    }

}
